package com.nc.delivery_project.shared.locator;

import com.google.web.bindery.requestfactory.shared.Locator;
import com.nc.delivery_project.server.domain.Payment;
import com.nc.delivery_project.server.service.PaymentService;
import com.nc.delivery_project.shared.servicelocator.PaymentServiceLocator;

/**
 * Created with IntelliJ IDEA.
 * User: Natalie D.
 * Date: 1/17/15
 * Time: 10:34 PM
 */
public class PaymentLocator extends Locator<Payment, Integer> {

    @Override
    public Payment create(Class<? extends Payment> clazz) {
        return new Payment();
    }

    @Override
    public Payment find(Class<? extends Payment> clazz, Integer id) {
        return ((PaymentService) new PaymentServiceLocator().getInstance(null)).read(id);
    }

    @Override
    public Class<Payment> getDomainType() {
        return Payment.class;
    }

    @Override
    public Integer getId(Payment domainObject) {
        return domainObject.getId();
    }

    @Override
    public Class<Integer> getIdType() {
        return Integer.class;
    }

    @Override
    public Object getVersion(Payment domainObject) {

        return domainObject.getId();
    }
}

